/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package db;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Alexey Chirkov
 */
public class SessionTableModel extends AbstractTableModel {

    private String[] name = {"N зачетки", "N сессии", "Предмет 1", "Предмет 2", "Предмет 3"};
    private Object[][] data;

    public SessionTableModel() {
        updateData();

    }

    public boolean addRecord(int studentID, int sessionID, double sub1, double sub2, double sub3) {
         try {
            updateData();
            return true;
        } catch (Exception ex) {
            return false;
        }

    }

    public void deleteRecord(int index) {
    }

    private void updateData() {
        data = new Object[name.length][2];
    }

    @Override
    public int getRowCount() {
        return data[0].length;
    }

    @Override
    public int getColumnCount() {
        return name.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return data[columnIndex][rowIndex];
    }

    public void setValueAt(Object val, int rowIndex, int columnIndex) {
        System.out.println("111");
        data[columnIndex][rowIndex] = val;
    }

    public String getColumnName(int i) {
        return name[i];
    }

    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return true;
    }
}
